;;;
;;; JaCoLiB
;;; Copyright (C) 2008 Alessandro Serra
;;; 
;;; This program is free software: you can redistribute it and/or modify
;;; it under the terms of the GNU General Public License as published by
;;; the Free Software Foundation, either version 3 of the License, or
;;; (at your option) any later version.
;;; 
;;; This program is distributed in the hope that it will be useful,
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;; GNU General Public License for more details.
;;; 
;;; You should have received a copy of the GNU General Public License
;;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
;;;

;;;; Created on 2008-07-25 18:41:19

(in-package :jacolib)

;
; RPC Client
;

(defclass rpc-client ()
  ((rpc-client-stub
    :TYPE rpc-client-stub
    :INITARG :rpc-client-stub
    :ACCESSOR rpc-client-client-stub))
  (:documentation "A rpc client."))

; functions

(defun rpc-client-quit (rpc-client)
  (declare (type rpc-client rpc-client))
  (rpc-client-stub-quit (rpc-client-client-stub rpc-client)))

(defun rpc-client-exec (client method params)
  (declare (type rpc-client client)
           (type string method))
  (rpc-response-get 
   (rpc-client-stub-exec (rpc-client-client-stub client)
                         (make-rpc-request
                          :method method 
                          :params params))))

; quiting

(defgeneric rpc-client-quit% (rpc-client)
  (:method ((rpc-client rpc-client))
    (rpc-client-stub-quit% (rpc-client-client-stub rpc-client))
    (setf (slot-value rpc-client 'rpc-client-stub) nil)))
